<?php

Class Template {
	
	private $vars = array();

	public function __construct() {
	}

	public function set($varname, $value, $overwrite=false) {
		if (isset($this->vars[$varname]) == true AND $overwrite == false) {
			throw new TemplateException(TemplateException::ERR_OVERWRITE_VAR);
		}

		$this->vars[$varname] = $value;
	}

	public function remove($varname) {
		unset($this->vars[$varname]);
		return true;
	}

	public function show($name) {
		$path = site_path . 'templates' . DIRSEP . $name . '.php';

		if (file_exists($path) == false) {
			throw new TemplateException(TemplateException::ERR_TEMPLATE_NOT_FOUND);
		}

		// Load variables
		foreach ($this->vars as $key => $value) {
			$$key = $value;
		}

		
		include ($path);		
	}

}

?>